<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>

<body>
<?php $ruta_raiz = "..";
	include("$ruta_raiz/adodb/adodb.inc.php");
	include("$ruta_raiz/config.php");
	$fechas = "";
	$db = NewADOConnection('mysql');
	$db->debug = true;
  	$db->Connect("$host", "$root_user", "$passwd", "$dbname");
	$sql = $_POST['sql'];
	$sql = strtr($sql,"\'", " ");
	print ($sql);
	$list = "listado.csv";
	$fp = fopen ($list, "w+");
	fwrite($fp, "documento, nombres, apellidos");
	$rs = $db->Execute($sql);
	while(!$rs->EOF){
	fwrite($fp, "\n".$rs->fields[0].','.$rs->fields[2].','.$rs->fields[1].'');
	$rs->MoveNext();
	//$rs = $db->Execute('update evento_invitado set inv_evn_certificado = 1 where inv_evn_evento = '.$evento.' && inv_evn_invitado = '.$docs[$i].';');
	}
	fclose($fp);
	echo("<script language='JavaScript' type='text/javascript'>");
	echo("location.href='./listado.csv'");
	echo("</script>");
	
	function array_recibe($url_array) {
     $tmp = stripslashes($url_array);
     $tmp = urldecode($tmp);
     $tmp = unserialize($tmp);

    return $tmp;
	} 
	echo("<script language='JavaScript' type='text/javascript'>");
	echo("location.href='./certificados.php'");
	echo("</script>");
	?>
    
</body>
</html>